
from flask import request
from . import app_update_need
from conn_mysql import ConnectMysql

@app_update_need.route('/update_need', methods = ['POST'])
def update_need():

    need = request.form.get('need')

    company_id = request.form.get('company_id')

    party = request.form.get("party")

    if not all([need, company_id, party]):

        return {
            'status': -1,
            'errorCode': 4,
            'errorMsg': '请检查请求参数，不能为空',
            'resultBody':None
        }

    sql = 'UPDATE company SET need=%s, party=%s WHERE id=%s'

    with ConnectMysql() as m:

        m.update_info(sql, (need, party, company_id))

    
    return {
        'status': 1,
        'errorCode': None,
        'errorMsg': None,
        'resultBody':"成功发布新的信息"
    }